package org.hrds.rdupm.harbor.infra.feign;

import java.util.List;

import org.hrds.rdupm.harbor.api.vo.ExternalTenantVO;
import org.hrds.rdupm.harbor.infra.feign.dto.UserDTO;
import org.hrds.rdupm.harbor.infra.feign.fallback.IamFeignClientFallBack;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;


/**
 * FeignDemo
 *
 * @author chenxiuhong
 */
@FeignClient(value = "zknow-iam", path = "/choerodon", fallback = IamFeignClientFallBack.class)
public interface IamFeignClient {

    /***
     * 根据用户名查询用户信息
     * @param loginName 登录名
     * @return
     */
    @GetMapping(value = "/v1/users")
    ResponseEntity<UserDTO> query(@RequestParam(value = "login_name") String loginName);

    /***
     * 根据id批量查询用户信息列表
     * @param ids 用户ID数组
     * @param onlyEnabled 是否查询启用用户
     * @return
     */
    @PostMapping(value = "/v1/users/ids")
    ResponseEntity<List<UserDTO>> listUsersByIds(@RequestBody Long[] ids, @RequestParam(value = "only_enabled", defaultValue = "true", required = false) Boolean onlyEnabled);

    /***
     * 根据loginName批量查询用户信息列表
     * @param loginNames 登录名数组
     * @param onlyEnabled 是否查询启用用户
     * @return
     */
    @PostMapping(value = "/v1/users/login_names")
    ResponseEntity<List<UserDTO>> listUsersByLoginNames(@RequestBody String[] loginNames, @RequestParam(value = "only_enabled", defaultValue = "true", required = false) Boolean onlyEnabled);

    @GetMapping("/v1/organizations/external/tenants")
    ResponseEntity<ExternalTenantVO> queryTenantByIdWithExternalInfo(@RequestParam("organization_id") Long organizationId);
}
